package vip.youngboy.freejump.handler.task;

import org.springframework.stereotype.Component;
import vip.youngboy.freejump.constant.TaskActionType;
import vip.youngboy.freejump.domain.FlowRequestParam;
import vip.youngboy.freejump.domain.TaskActionModel;
import vip.youngboy.freejump.domain.process.Option;

import java.util.List;
import java.util.Map;

@Component
public class TaskAgreeActionHandler extends AbstractTaskActionHandler {

    @Override
    public void doHandleAction(TaskActionModel taskActionModel) {
        FlowRequestParam flowRequestParam = taskActionModel.getFlowRequestParam();
        String taskId = flowRequestParam.getTaskId();
        String assign = taskActionModel.getAssign();
        Map<String, Object> variables = flowRequestParam.getVariables();
        //是否需要认领任务
        taskService.claim(taskId, assign);
        taskService.complete(taskId, variables);
    }

    @Override
    public void vaildOptions(FlowRequestParam flowRequestParam) {

    }

    @Override
    public TaskActionType supportAction() {
        return TaskActionType.AGREE;
    }

    @Override
    public List<Option> getOptions() {
        return null;
    }

}
